package net.niufei.study.cpatterns.producerconsumer;

public class Consumer implements Runnable {
	private final Resource resource;
	
	public Consumer(Resource resource) {
		this.resource = resource;
	}

	@Override
	public void run() {
		while (true) {
			try {
				String str = resource.fetch();
				System.out.println(Thread.currentThread().getName()
						+ " fetch resource:" + str);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

		}
	}

	
}
